package ArrayList;

import java.util.ArrayList;

public class Phone_test {
    public static void main(String[] args) {
        ArrayList<Phone> list=new ArrayList<>();
        Phone p1=new Phone(2000,"mi");
        Phone p2=new Phone(3000,"iphone");
        Phone p3=new Phone(4000,"huawei");
        list.add(p1);
        list.add(p2);
        list.add(p3);
        System.out.println(getInforment(list));

    }
    public static String getInforment(ArrayList<Phone> list){
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getPrice()<3000){
                return list.get(i).getName()+" "+list.get(i).getPrice();
            }
        }
        return "没有价格低于3000的手机";
    }
}
